<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改房间信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-room-edit" th:object="${room}">
            <input name="roomId" th:field="*{roomId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">房间名称：</label>
                <div class="col-sm-8">
                    <input name="roomName" th:field="*{roomName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">房间类型：</label>
                <div class="col-sm-8">
                    <select name="categroyId" class="form-control m-b" th:with="type=${@dict.getType('room_cate')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{categroyId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">房间状态：</label>
                <div class="col-sm-8">
                    <select name="roomStatus" class="form-control m-b" th:with="type=${@dict.getType('room_status')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{roomStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">房间图片：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="roomPicture" th:field="*{roomPicture}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="roomPicture" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">房间备注：</label>
                <div class="col-sm-9">
                    <label class="check-box">
                        <input type="checkbox" value="option1" id="inlineCheckbox1">选项1</label>
                    <label class="check-box">
                        <input type="checkbox" value="option2" id="inlineCheckbox2">选项2</label>
                    <label class="check-box">
                        <input type="checkbox" value="option3" id="inlineCheckbox3">选项3</label>
                    <label class="check-box">
                        <input type="checkbox" value="option3" id="inlineCheckbox4">选项4</label>
                    <label class="check-box">
                        <input type="checkbox" value="option3" id="inlineCheckbox5">选项5</label>

                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/room";
        $("#form-room-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-room-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>